﻿using Microsoft.Extensions.Caching.Distributed;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Fast.Extensions.Caching
{
    /// <summary>
    /// 缓存支持多项操作
    /// </summary>
    public interface ICacheSupportsMultipleItems
    {
        /// <summary>
        /// 获取指定缓存键的多个缓存项
        /// </summary>
        /// <param name="keys">要从缓存中检索的缓存项的键</param>
        /// <returns></returns>
        byte[][] GetMany(
            IEnumerable<string> keys
        );

        /// <summary>
        /// 获取指定缓存键的多个缓存项
        /// </summary>
        /// <param name="keys">要从缓存中检索的缓存项的键</param>
        /// <param name="token">任务的 <see cref="T:System.Threading.CancellationToken" /></param>
        /// <returns></returns>
        Task<byte[][]> GetManyAsync(
            IEnumerable<string> keys,
            CancellationToken token = default
        );

        /// <summary>
        /// 设置多个缓存项
        /// </summary>
        /// <param name="items">要在缓存上设置的项</param>
        /// <param name="options">值的缓存选项</param>
        void SetMany(
            IEnumerable<KeyValuePair<string, byte[]>> items,
            DistributedCacheEntryOptions options
        );

        /// <summary>
        /// 设置多个缓存项
        /// </summary>
        /// <param name="items">要在缓存上设置的项</param>
        /// <param name="options">值的缓存选项</param>
        /// <param name="token">任务的 <see cref="T:System.Threading.CancellationToken" /></param>
        /// <returns></returns>
        Task SetManyAsync(
            IEnumerable<KeyValuePair<string, byte[]>> items,
            DistributedCacheEntryOptions options,
            CancellationToken token = default
        );

        /// <summary>
        /// 刷新指定缓存键的缓存值，并重置其滑动过期超时
        /// </summary>
        /// <param name="keys">要从缓存中检索的缓存项的键</param>
        void RefreshMany(
            IEnumerable<string> keys
        );

        /// <summary>
        /// 刷新指定缓存键的缓存值，并重置其滑动过期超时
        /// </summary>
        /// <param name="keys">要从缓存中检索的缓存项的键</param>
        /// <param name="token">任务的 <see cref="T:System.Threading.CancellationToken" /></param>
        /// <returns></returns>
        Task RefreshManyAsync(
            IEnumerable<string> keys,
            CancellationToken token = default
        );

        /// <summary>
        /// 从缓存中删除指定缓存键的缓存项
        /// </summary>
        /// <param name="keys">要从缓存中检索的缓存项的键</param>
        void RemoveMany(
            IEnumerable<string> keys
        );

        /// <summary>
        /// 从缓存中删除指定缓存键的缓存项
        /// </summary>
        /// <param name="keys">要从缓存中检索的缓存项的键</param>
        /// <param name="token">任务的 <see cref="T:System.Threading.CancellationToken" /></param>
        /// <returns></returns>
        Task RemoveManyAsync(
            IEnumerable<string> keys,
            CancellationToken token = default
        );
    }
}
